<?php

namespace DebugComponent\Plugin;

class Version implements \DebugComponent\IPlugin, \DebugComponent\IRenderable {

    public function __construct(array $versions=array()) {
        $this->versions = $versions;
        $this->mainVersion = null;
    }

    public function addVersion($name, $version) {
        $this->versions[$name] = $version;
    }

    public function setMainVersion($version) {
        $this->mainVersion = $version;
    }

    public function setRenderer(\DebugComponent\IRenderer $renderer) {
        $this->renderer = $renderer;
    }

    public function getTitle() {
        return 'Version';
    }

    public function getSubtitle() {
        return $this->mainVersion;
    }

    public function render() {
        $data = new \DebugComponent\ParameterHolder();
        $data->set('versions', $this->versions);
        $data->set('title', $this->getTitle());
        $data->set('subtitle', $this->getSubtitle());
        return $this->renderer->render($data);
    }

    private $mainVersion;
    private $versions;
    private $renderer;
}